{%insert header.tpl%}
<script type="text/javascript" src="{% $THEME_URL %}/js/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="{% $THEME_URL %}/js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="{% $THEME_URL %}/js/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript">
$(document).ready(function() {$("a.imageloader").fancybox();});
</script>
<h2>Ваша корзина</h2>
<fieldset class="cart" title="Товары">
	<legend>Товары</legend>
	<form id="cart_form" method="post">
	<input type="hidden" name="method" value="Save" />
	<table>
		<tr><th></th><th>Наименование</th><th>Цена</th><th>Количество</th><th>Стоимость</th><th></th></tr>
	{%iterate Positions as position %}
		<tr{%odd%} class="odd"{%endodd%}>
			{%with Product%}
				{%assign prodid Id%}
			<td class="icon">
				{%if Icon%}
					{%with Icon%}
						<a class="imageloader" href="{% GetLink %}"><img src="{% GetThumbnailLink %}" /></a>
					{%endwith%}
				{%endif%}
			</td>
			<td class="name">{% context %}</td>
			<td class="price">{% Price %} руб.</td>
			{%endwith%}
			<td class="quantaty">
			<input type="text" name="cart[{% prodid %}]" value="{% Quantaty %}" />
			</td>
			<td class="cost">
			{% Cost %}&nbsp;руб.
			</td>
			<td class="delete">
			<a href="{% DeleteUrl < prodid %}"><button type="button" class="cart-del-btn" title="Удалить">Удалить</button></a>
			</td>
		</tr>
	{%iterate%}
		<tr class="total"><td></td><td colspan="3">Итого</td><td class="cost">{% TotalSum %}&nbsp;руб.</td><td></td></tr>
	</table>
	</form>	
	<form id="clear_form" method="post">
		<input type="hidden" name="method" value="Clear" />
	</form>
	<div class="btn-holder">
		<button type="button" onclick="javascript:if (check_cart_not_empty()) $(&quot;#cart_form&quot;).submit(); else {alert(&quot;Ваша корзина пуста!&quot;);return false;}">Применить</button>
		<button type="button" onclick="javascript:$(&quot;#clear_form&quot;).submit();">Сброс</button>
		<a href="{% OrderUrl %}"><button type="button">Заказать</button></a>
	</div>
</fieldset>
<script language="javascript">
	function check_cart_not_empty(){
		var cart = $('#cart_form td.quantaty input[type=\'text\']');
		return cart.length > 0;
	}
</script>
{%insert footer.tpl%}
